package com.yunhe.authority.service.authority;

import com.yunhe.authority.domain.authority.Role;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.PageParam;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 角色Service
 * @desc 角色服务类定义
 * @author liuronglei
 */
public interface CompanyRoleService {

    /**
     * 新增角色
     * @param companyId 企业ID
     * @param role      角色对象
     * @return Role
     * @throws ArgumentErrorException
     * @throws UniqueConstraintsException
     * @throws ObjectNotFoundException
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    Role createRole(Long companyId, Role role)
            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException;

    /**
     * 更新角色
     * @param companyId 企业ID
     * @param role 要更新的角色对象
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    Role updateRole(Long companyId, Role role)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException;

    /**
     * 根据企业ID查询角色
     * @param companyId 企业ID
     * @return List<Role>
     */
    Iterable<Role> findRolesByCompanyId(Long companyId);

    /**
     * 根据企业ID查询角色(分页)
     * @param companyId 企业ID
     * @param keywords 关键词
     * @param pageParam 分页
     * @return Page
     */
    Page<Role> findRolesByCompanyIdForPage(Long companyId, String keywords, PageParam pageParam);

}
